package nagel_schreckenberg;

import java.awt.Color;
import java.awt.Dimension;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.geom.Ellipse2D;
import java.util.ArrayList;

import javax.swing.JPanel;

public class Panel2 extends JPanel{
	
	private ArrayList<Ellipse2D> vehicles;
	private ArrayList<Double> cis;
	private Environment env;
	private double str = 5;
	private int rounds;
	private int insys;
	
	public Panel2(int w, int h){
		setPreferredSize(new Dimension(w, h));
		cis = new ArrayList<Double>();
		rounds = 0;
		insys = 0;
	}

	public void updateGraphics(Environment e){
		vehicles = new ArrayList<Ellipse2D>();
		env = e;
		int x; int y;
		//i1
		for(Vehicle v : e.getLanes().get(0).getVehicles()){
			x = 130;
			y = 20 + v.getPosition();
			vehicles.add(new Ellipse2D.Double(x-str/2, y-str/2, str, str));
		}
		for(Vehicle v : e.getLanes().get(1).getVehicles()){
			x = 150;
			y = 120 - v.getPosition();
			vehicles.add(new Ellipse2D.Double(x-str/2, y-str/2, str, str));
		}
		for(Vehicle v : e.getLanes().get(2).getVehicles()){
			x = 260 - v.getPosition();
			y = 130;
			vehicles.add(new Ellipse2D.Double(x-str/2, y-str/2, str, str));
		}
		for(Vehicle v : e.getLanes().get(3).getVehicles()){
			x = 160 + v.getPosition();
			y = 150;
			vehicles.add(new Ellipse2D.Double(x-str/2, y-str/2, str, str));
		}
		for(Vehicle v : e.getLanes().get(4).getVehicles()){
			x = 150;
			y = 260 - v.getPosition();
			vehicles.add(new Ellipse2D.Double(x-str/2, y-str/2, str, str));
		}
		for(Vehicle v : e.getLanes().get(5).getVehicles()){
			x = 130;
			y = 160 + v.getPosition();
			vehicles.add(new Ellipse2D.Double(x-str/2, y-str/2, str, str));
		}
		for(Vehicle v : e.getLanes().get(6).getVehicles()){
			x = 20 + v.getPosition();
			y = 150;
			vehicles.add(new Ellipse2D.Double(x-str/2, y-str/2, str, str));
		}
		for(Vehicle v : e.getLanes().get(7).getVehicles()){
			x = 120 - v.getPosition();
			y = 130;
			vehicles.add(new Ellipse2D.Double(x-str/2, y-str/2, str, str));
		}
		//i2
		for(Vehicle v : e.getLanes().get(8).getVehicles()){
			x = 270;
			y = 20 + v.getPosition();
			vehicles.add(new Ellipse2D.Double(x-str/2, y-str/2, str, str));
		}
		for(Vehicle v : e.getLanes().get(9).getVehicles()){
			x = 290;
			y = 120 - v.getPosition();
			vehicles.add(new Ellipse2D.Double(x-str/2, y-str/2, str, str));
		}
		for(Vehicle v : e.getLanes().get(10).getVehicles()){
			x = 400 - v.getPosition();
			y = 130;
			vehicles.add(new Ellipse2D.Double(x-str/2, y-str/2, str, str));
		}
		for(Vehicle v : e.getLanes().get(11).getVehicles()){
			x = 300 + v.getPosition();
			y = 150;
			vehicles.add(new Ellipse2D.Double(x-str/2, y-str/2, str, str));
		}
		for(Vehicle v : e.getLanes().get(12).getVehicles()){
			x = 290;
			y = 260 - v.getPosition();
			vehicles.add(new Ellipse2D.Double(x-str/2, y-str/2, str, str));
		}
		for(Vehicle v : e.getLanes().get(13).getVehicles()){
			x = 270;
			y = 160 + v.getPosition();
			vehicles.add(new Ellipse2D.Double(x-str/2, y-str/2, str, str));
		}
		//i3
		for(Vehicle v : e.getLanes().get(14).getVehicles()){
			x = 410;
			y = 20 + v.getPosition();
			vehicles.add(new Ellipse2D.Double(x-str/2, y-str/2, str, str));
		}
		for(Vehicle v : e.getLanes().get(15).getVehicles()){
			x = 430;
			y = 120 - v.getPosition();
			vehicles.add(new Ellipse2D.Double(x-str/2, y-str/2, str, str));
		}
		for(Vehicle v : e.getLanes().get(16).getVehicles()){
			x = 540 - v.getPosition();
			y = 130;
			vehicles.add(new Ellipse2D.Double(x-str/2, y-str/2, str, str));
		}
		for(Vehicle v : e.getLanes().get(17).getVehicles()){
			x = 440 + v.getPosition();
			y = 150;
			vehicles.add(new Ellipse2D.Double(x-str/2, y-str/2, str, str));
		}
		for(Vehicle v : e.getLanes().get(18).getVehicles()){
			x = 430;
			y = 260 - v.getPosition();
			vehicles.add(new Ellipse2D.Double(x-str/2, y-str/2, str, str));
		}
		for(Vehicle v : e.getLanes().get(19).getVehicles()){
			x = 410;
			y = 160 + v.getPosition();
			vehicles.add(new Ellipse2D.Double(x-str/2, y-str/2, str, str));
		}
		//i4
		for(Vehicle v : e.getLanes().get(20).getVehicles()){
			x = 260 - v.getPosition();
			y = 270;
			vehicles.add(new Ellipse2D.Double(x-str/2, y-str/2, str, str));
		}
		for(Vehicle v : e.getLanes().get(21).getVehicles()){
			x = 160 + v.getPosition();
			y = 290;
			vehicles.add(new Ellipse2D.Double(x-str/2, y-str/2, str, str));
		}
		for(Vehicle v : e.getLanes().get(22).getVehicles()){
			x = 150;
			y = 400 - v.getPosition();
			vehicles.add(new Ellipse2D.Double(x-str/2, y-str/2, str, str));
		}
		for(Vehicle v : e.getLanes().get(23).getVehicles()){
			x = 130;
			y = 300 + v.getPosition();
			vehicles.add(new Ellipse2D.Double(x-str/2, y-str/2, str, str));
		}
		for(Vehicle v : e.getLanes().get(24).getVehicles()){
			x = 20 + v.getPosition();
			y = 290;
			vehicles.add(new Ellipse2D.Double(x-str/2, y-str/2, str, str));
		}
		for(Vehicle v : e.getLanes().get(25).getVehicles()){
			x = 120 - v.getPosition();
			y = 270;
			vehicles.add(new Ellipse2D.Double(x-str/2, y-str/2, str, str));
		}
		//im
		for(Vehicle v : e.getLanes().get(26).getVehicles()){
			x = 400 - v.getPosition();
			y = 270;
			vehicles.add(new Ellipse2D.Double(x-str/2, y-str/2, str, str));
		}
		for(Vehicle v : e.getLanes().get(27).getVehicles()){
			x = 300 + v.getPosition();
			y = 290;
			vehicles.add(new Ellipse2D.Double(x-str/2, y-str/2, str, str));
		}
		for(Vehicle v : e.getLanes().get(28).getVehicles()){
			x = 290;
			y = 400 - v.getPosition();
			vehicles.add(new Ellipse2D.Double(x-str/2, y-str/2, str, str));
		}
		for(Vehicle v : e.getLanes().get(29).getVehicles()){
			x = 270;
			y = 300 + v.getPosition();
			vehicles.add(new Ellipse2D.Double(x-str/2, y-str/2, str, str));
		}
		//i5
		for(Vehicle v : e.getLanes().get(30).getVehicles()){
			x = 540 - v.getPosition();
			y = 270;
			vehicles.add(new Ellipse2D.Double(x-str/2, y-str/2, str, str));
		}
		for(Vehicle v : e.getLanes().get(31).getVehicles()){
			x = 440 + v.getPosition();
			y = 290;
			vehicles.add(new Ellipse2D.Double(x-str/2, y-str/2, str, str));
		}
		for(Vehicle v : e.getLanes().get(32).getVehicles()){
			x = 430;
			y = 400 - v.getPosition();
			vehicles.add(new Ellipse2D.Double(x-str/2, y-str/2, str, str));
		}
		for(Vehicle v : e.getLanes().get(33).getVehicles()){
			x = 410;
			y = 300 + v.getPosition();
			vehicles.add(new Ellipse2D.Double(x-str/2, y-str/2, str, str));
		}
		//i6
		for(Vehicle v : e.getLanes().get(34).getVehicles()){
			x = 260 - v.getPosition();
			y = 410;
			vehicles.add(new Ellipse2D.Double(x-str/2, y-str/2, str, str));
		}
		for(Vehicle v : e.getLanes().get(35).getVehicles()){
			x = 160 + v.getPosition();
			y = 430;
			vehicles.add(new Ellipse2D.Double(x-str/2, y-str/2, str, str));
		}
		for(Vehicle v : e.getLanes().get(36).getVehicles()){
			x = 150;
			y = 540 - v.getPosition();
			vehicles.add(new Ellipse2D.Double(x-str/2, y-str/2, str, str));
		}
		for(Vehicle v : e.getLanes().get(37).getVehicles()){
			x = 130;
			y = 440 + v.getPosition();
			vehicles.add(new Ellipse2D.Double(x-str/2, y-str/2, str, str));
		}
		for(Vehicle v : e.getLanes().get(38).getVehicles()){
			x = 20 + v.getPosition();
			y = 430;
			vehicles.add(new Ellipse2D.Double(x-str/2, y-str/2, str, str));
		}
		for(Vehicle v : e.getLanes().get(39).getVehicles()){
			x = 120 - v.getPosition();
			y = 410;
			vehicles.add(new Ellipse2D.Double(x-str/2, y-str/2, str, str));
		}
		//i7
		for(Vehicle v : e.getLanes().get(40).getVehicles()){
			x = 400 - v.getPosition();
			y = 410;
			vehicles.add(new Ellipse2D.Double(x-str/2, y-str/2, str, str));
		}
		for(Vehicle v : e.getLanes().get(41).getVehicles()){
			x = 300 + v.getPosition();
			y = 430;
			vehicles.add(new Ellipse2D.Double(x-str/2, y-str/2, str, str));
		}
		for(Vehicle v : e.getLanes().get(42).getVehicles()){
			x = 290;
			y = 540 - v.getPosition();
			vehicles.add(new Ellipse2D.Double(x-str/2, y-str/2, str, str));
		}
		for(Vehicle v : e.getLanes().get(43).getVehicles()){
			x = 270;
			y = 440 + v.getPosition();
			vehicles.add(new Ellipse2D.Double(x-str/2, y-str/2, str, str));
		}
		//i8
		for(Vehicle v : e.getLanes().get(44).getVehicles()){
			x = 540 - v.getPosition();
			y = 410;
			vehicles.add(new Ellipse2D.Double(x-str/2, y-str/2, str, str));
		}
		for(Vehicle v : e.getLanes().get(45).getVehicles()){
			x = 440 + v.getPosition();
			y = 430;
			vehicles.add(new Ellipse2D.Double(x-str/2, y-str/2, str, str));
		}
		for(Vehicle v : e.getLanes().get(46).getVehicles()){
			x = 430 ;
			y = 540 - v.getPosition();
			vehicles.add(new Ellipse2D.Double(x-str/2, y-str/2, str, str));
		}
		for(Vehicle v : e.getLanes().get(47).getVehicles()){
			x = 410 ;
			y = 440 + v.getPosition();
			vehicles.add(new Ellipse2D.Double(x-str/2, y-str/2, str, str));
		}
	}
	
	public void updateInformation(double c){
		insys = (int)c;
		cis.add(c);
	}
	public void paintComponent(Graphics g) {
		super.paintComponent(g);
	    Graphics2D g2 = (Graphics2D)g;
	    g2.setPaint(Color.black);
	    rounds++;
	    g2.drawLine(560, 200, 560, 250);
	    g2.drawLine(560, 250, 660, 250);
	    double currentMax = 0;
	    for(int i = 0; i < cis.size(); i++){
	    	if(cis.get(i) > currentMax){
	    		currentMax = cis.get(i);
	    	}
	    	Ellipse2D el = new Ellipse2D.Double((560 + (int)((i/(double)cis.size())*100)), (249 - (int)((cis.get(i))/3)), 1, 1);
	    	//TODO change scale for y coordinate
	    	g2.draw(el);
	    }
	    g2.drawString("Cars: " + insys + "", 560, 270);
	    g2.drawString("Max. cars: " + (int)currentMax, 560, 290);
	    g2.drawLine(560, 300, 560 + (int)((rounds/(double)Config.SIMITERATIONS) * 100), 300);
	    g2.drawLine(560, 305, 560 + (int)((rounds/(double)Config.SIMITERATIONS) * 100), 305);
	    g2.drawLine(560, 300, 560, 305);
	    g2.drawLine(660, 300, 660, 305);
	    g2.drawString("Round: " + rounds + " / " + Config.SIMITERATIONS + "", 560, 320);
	    try{
	    	
	    for(Ellipse2D e : vehicles){
	    	g2.draw(e);
	    }
	    //i1
		g2.drawLine(130, 20, 130, 120); g2.drawLine(150, 20, 150, 120);
		g2.drawLine(160, 130, 260, 130); g2.drawLine(160, 150, 260, 150);
		g2.drawLine(130, 160, 130, 260); g2.drawLine(150, 160, 150, 260);
		g2.drawLine(20, 130, 120, 130); g2.drawLine(20, 150, 120, 150);
		g2.drawRect(120, 120, 40, 40);
		//i2
		g2.drawLine(270, 20, 270, 120); g2.drawLine(290, 20, 290, 120);
		g2.drawLine(300, 130, 400, 130); g2.drawLine(300, 150, 400, 150);
		g2.drawLine(270, 160, 270, 260); g2.drawLine(290, 160, 290, 260);
		g2.drawRect(260, 120, 40, 40);
		//i3
		g2.drawLine(410, 20, 410, 120); g2.drawLine(430, 20, 430, 120);
		g2.drawLine(440, 130, 540, 130); g2.drawLine(440, 150, 540, 150);
		g2.drawLine(410, 160, 410, 260); g2.drawLine(430, 160, 430, 260);
		g2.drawRect(400, 120, 40, 40);
		//i4
		g2.drawLine(160, 270, 260, 270); g2.drawLine(160, 290, 260, 290);
		g2.drawLine(130, 300, 130, 400); g2.drawLine(150, 300, 150, 400);
		g2.drawLine(20, 270, 120, 270); g2.drawLine(20, 290, 120, 290);
		g2.drawRect(120, 260, 40, 40);
		//im
		g2.drawLine(300, 270, 400, 270); g2.drawLine(300, 290, 400, 290);
		g2.drawLine(270, 300, 270, 400); g2.drawLine(290, 300, 290, 400);
		g2.drawRect(260, 260, 40, 40);
		//i5
		g2.drawLine(440, 270, 540, 270); g2.drawLine(440, 290, 540, 290);
		g2.drawLine(410, 300, 410, 400); g2.drawLine(430, 300, 430, 400);
		g2.drawRect(400, 260, 40, 40);
		//i6
		g2.drawLine(160, 410, 260, 410); g2.drawLine(160, 430, 260, 430);
		g2.drawLine(130, 440, 130, 540); g2.drawLine(150, 440, 150, 540);
		g2.drawLine(20, 410, 120, 410); g2.drawLine(20, 430, 120, 430);
		g2.drawRect(120, 400, 40, 40);
		//i7
		g2.drawLine(300, 410, 400, 410); g2.drawLine(300, 430, 400, 430);
		g2.drawLine(270, 440, 270, 540); g2.drawLine(290, 440, 290, 540);
		g2.drawRect(260, 400, 40, 40);
		//i8
		g2.drawLine(440, 410, 540, 410); g2.drawLine(440, 430, 540, 430);
		g2.drawLine(410, 440, 410, 540); g2.drawLine(430, 440, 430, 540);
		g2.drawRect(400, 400, 40, 40);
		//i1
		Ellipse2D n1 = new Ellipse2D.Double(125, 115, str, str);
	    if(env.getLanes().get(0).getPhase()){g2.setPaint(Color.green);}else{g2.setPaint(Color.red);}
	    g2.fill(n1);
	    g2.draw(n1);
	    Ellipse2D e1 = new Ellipse2D.Double(160, 125, str, str);
	    if(env.getLanes().get(2).getPhase()){g2.setPaint(Color.green);}else{g2.setPaint(Color.red);}
	    g2.fill(e1);
	    g2.draw(e1);
	    Ellipse2D w2 = new Ellipse2D.Double(255, 150, str, str);
	    if(env.getLanes().get(3).getPhase()){g2.setPaint(Color.green);}else{g2.setPaint(Color.red);}
	    g2.fill(w2);
	    g2.draw(w2);
	    Ellipse2D s1 = new Ellipse2D.Double(150, 160, str, str);
	    if(env.getLanes().get(4).getPhase()){g2.setPaint(Color.green);}else{g2.setPaint(Color.red);}
	    g2.fill(s1);
	    g2.draw(s1);
	    Ellipse2D n4 = new Ellipse2D.Double(125, 255, str, str);
	    if(env.getLanes().get(5).getPhase()){g2.setPaint(Color.green);}else{g2.setPaint(Color.red);}
	    g2.fill(n4);
	    g2.draw(n4);
	    Ellipse2D w1 = new Ellipse2D.Double(115, 150, str, str);
	    if(env.getLanes().get(6).getPhase()){g2.setPaint(Color.green);}else{g2.setPaint(Color.red);}
	    g2.fill(w1);
	    g2.draw(w1);
	    //i2
	    Ellipse2D n2 = new Ellipse2D.Double(265, 115, str, str);
	    if(env.getLanes().get(8).getPhase()){g2.setPaint(Color.green);}else{g2.setPaint(Color.red);}
	    g2.fill(n2);
	    g2.draw(n2);
	    Ellipse2D e2 = new Ellipse2D.Double(300, 125, str, str);
	    if(env.getLanes().get(10).getPhase()){g2.setPaint(Color.green);}else{g2.setPaint(Color.red);}
	    g2.fill(e2);
	    g2.draw(e2);
	    Ellipse2D w3 = new Ellipse2D.Double(395, 150, str, str);
	    if(env.getLanes().get(11).getPhase()){g2.setPaint(Color.green);}else{g2.setPaint(Color.red);}
	    g2.fill(w3);
	    g2.draw(w3);
	    Ellipse2D s2 = new Ellipse2D.Double(290, 160, str, str);
	    if(env.getLanes().get(12).getPhase()){g2.setPaint(Color.green);}else{g2.setPaint(Color.red);}
	    g2.fill(s2);
	    g2.draw(s2);
	    Ellipse2D ni = new Ellipse2D.Double(265, 255, str, str);
	    if(env.getLanes().get(13).getPhase()){g2.setPaint(Color.green);}else{g2.setPaint(Color.red);}
	    g2.fill(ni);
	    g2.draw(ni);
	    //i3
	    Ellipse2D n3 = new Ellipse2D.Double(405, 115, str, str);
	    if(env.getLanes().get(14).getPhase()){g2.setPaint(Color.green);}else{g2.setPaint(Color.red);}
	    g2.fill(n3);
	    g2.draw(n3);
	    Ellipse2D e3 = new Ellipse2D.Double(440, 125, str, str);
	    if(env.getLanes().get(16).getPhase()){g2.setPaint(Color.green);}else{g2.setPaint(Color.red);}
	    g2.fill(e3);
	    g2.draw(e3);
	    Ellipse2D s3 = new Ellipse2D.Double(430, 160, str, str);
	    if(env.getLanes().get(18).getPhase()){g2.setPaint(Color.green);}else{g2.setPaint(Color.red);}
	    g2.fill(s3);
	    g2.draw(s3);
	    Ellipse2D n5 = new Ellipse2D.Double(405, 255, str, str);
	    if(env.getLanes().get(19).getPhase()){g2.setPaint(Color.green);}else{g2.setPaint(Color.red);}
	    g2.fill(n5);
	    g2.draw(n5);
	    //i4
	    Ellipse2D e4 = new Ellipse2D.Double(160, 265, str, str);
	    if(env.getLanes().get(20).getPhase()){g2.setPaint(Color.green);}else{g2.setPaint(Color.red);}
	    g2.fill(e4);
	    g2.draw(e4);
	    Ellipse2D wi = new Ellipse2D.Double(255, 290, str, str);
	    if(env.getLanes().get(21).getPhase()){g2.setPaint(Color.green);}else{g2.setPaint(Color.red);}
	    g2.fill(wi);
	    g2.draw(wi);
	    Ellipse2D s4 = new Ellipse2D.Double(150, 300, str, str);
	    if(env.getLanes().get(22).getPhase()){g2.setPaint(Color.green);}else{g2.setPaint(Color.red);}
	    g2.fill(s4);
	    g2.draw(s4);
	    Ellipse2D n6 = new Ellipse2D.Double(125, 395, str, str);
	    if(env.getLanes().get(23).getPhase()){g2.setPaint(Color.green);}else{g2.setPaint(Color.red);}
	    g2.fill(n6);
	    g2.draw(n6);
	    Ellipse2D w4 = new Ellipse2D.Double(115, 290, str, str);
	    if(env.getLanes().get(24).getPhase()){g2.setPaint(Color.green);}else{g2.setPaint(Color.red);}
	    g2.fill(w4);
	    g2.draw(w4);
	    //im
	    Ellipse2D ei = new Ellipse2D.Double(300, 265, str, str);
	    if(env.getLanes().get(26).getPhase()){g2.setPaint(Color.green);}else{g2.setPaint(Color.red);}
	    g2.fill(ei);
	    g2.draw(ei);
	    Ellipse2D w5 = new Ellipse2D.Double(395, 290, str, str);
	    if(env.getLanes().get(27).getPhase()){g2.setPaint(Color.green);}else{g2.setPaint(Color.red);}
	    g2.fill(w5);
	    g2.draw(w5);
	    Ellipse2D si = new Ellipse2D.Double(290, 300, str, str);
	    if(env.getLanes().get(28).getPhase()){g2.setPaint(Color.green);}else{g2.setPaint(Color.red);}
	    g2.fill(si);
	    g2.draw(si);
	    Ellipse2D n7 = new Ellipse2D.Double(265, 395, str, str);
	    if(env.getLanes().get(29).getPhase()){g2.setPaint(Color.green);}else{g2.setPaint(Color.red);}
	    g2.fill(n7);
	    g2.draw(n7);
	    //i5
	    Ellipse2D e5 = new Ellipse2D.Double(440, 265, str, str);
	    if(env.getLanes().get(30).getPhase()){g2.setPaint(Color.green);}else{g2.setPaint(Color.red);}
	    g2.fill(e5);
	    g2.draw(e5);
	    Ellipse2D s5 = new Ellipse2D.Double(430, 300, str, str);
	    if(env.getLanes().get(32).getPhase()){g2.setPaint(Color.green);}else{g2.setPaint(Color.red);}
	    g2.fill(s5);
	    g2.draw(s5);
	    Ellipse2D n8 = new Ellipse2D.Double(405, 395, str, str);
	    if(env.getLanes().get(33).getPhase()){g2.setPaint(Color.green);}else{g2.setPaint(Color.red);}
	    g2.fill(n8);
	    g2.draw(n8);
	    //i6
	    Ellipse2D e6 = new Ellipse2D.Double(160, 405, str, str);
	    if(env.getLanes().get(34).getPhase()){g2.setPaint(Color.green);}else{g2.setPaint(Color.red);}
	    g2.fill(e6);
	    g2.draw(e6);
	    Ellipse2D w7 = new Ellipse2D.Double(255, 430, str, str);
	    if(env.getLanes().get(35).getPhase()){g2.setPaint(Color.green);}else{g2.setPaint(Color.red);}
	    g2.fill(w7);
	    g2.draw(w7);
	    Ellipse2D s6 = new Ellipse2D.Double(150, 440, str, str);
	    if(env.getLanes().get(36).getPhase()){g2.setPaint(Color.green);}else{g2.setPaint(Color.red);}
	    g2.fill(s6);
	    g2.draw(s6);
	    Ellipse2D w6 = new Ellipse2D.Double(115, 430, str, str);
	    if(env.getLanes().get(38).getPhase()){g2.setPaint(Color.green);}else{g2.setPaint(Color.red);}
	    g2.fill(w6);
	    g2.draw(w6);
	    //i7
	    Ellipse2D e7 = new Ellipse2D.Double(300, 405, str, str);
	    if(env.getLanes().get(40).getPhase()){g2.setPaint(Color.green);}else{g2.setPaint(Color.red);}
	    g2.fill(e7);
	    g2.draw(e7);
	    Ellipse2D w8 = new Ellipse2D.Double(395, 430, str, str);
	    if(env.getLanes().get(41).getPhase()){g2.setPaint(Color.green);}else{g2.setPaint(Color.red);}
	    g2.fill(w8);
	    g2.draw(w8);
	    Ellipse2D s7 = new Ellipse2D.Double(290, 440, str, str);
	    if(env.getLanes().get(42).getPhase()){g2.setPaint(Color.green);}else{g2.setPaint(Color.red);}
	    g2.fill(s7);
	    g2.draw(s7);
	    //i8
	    Ellipse2D e8 = new Ellipse2D.Double(440, 405, str, str);
	    if(env.getLanes().get(44).getPhase()){g2.setPaint(Color.green);}else{g2.setPaint(Color.red);}
	    g2.fill(e8);
	    g2.draw(e8);
	    Ellipse2D s8 = new Ellipse2D.Double(430, 440, str, str);
	    if(env.getLanes().get(46).getPhase()){g2.setPaint(Color.green);}else{g2.setPaint(Color.red);}
	    g2.fill(s8);
	    g2.draw(s8);
	    
	    }catch(Exception e){System.out.println("no Graphics available");}
	}
}
